import 'package:flutter/material.dart';

/// 一些杂七杂八的
class SomeChowdersPage extends StatefulWidget {
  final Map<String, dynamic> arguments;
  SomeChowdersPage({Key key, this.arguments}) : super(key: key);

  @override
  _SomeChowdersPageState createState() => _SomeChowdersPageState();
}

class _SomeChowdersPageState extends State<SomeChowdersPage> {
  var _linearProgress = 0.0;
  var _circularProgress = 0.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('SomeChowdersPage'), 
      ),
      body: ListView(
        children: <Widget>[
          ListTile(
            title: Text('自定义 Icon'),
            subtitle: Icon(
              IconData(0x661f, fontFamily: 'ZhiMangXing'), // 可以从 http://tool.chinaz.com/tools/unicode.aspx 获得 unicode 值
              size: 100,
              color: Colors.green,
            ),
          ),
          Divider(height: 1.0),
          ListTile(
            title: Text('Use a custom font'),
            subtitle: Text(
              '使用自定义字体',
              style: TextStyle(fontFamily: 'ZhiMangXing', fontSize: 30.0),
            ),
          ),
          Divider(height: 1.0),
          ListTile(
            title: Text('''
GestureDetector'''),
            subtitle: Center(
              child: GestureDetector(
                child: Container(
                  width: 100.0,
                  height: 40.0,
                  color: Colors.red,
                ),
                onTapDown: (details) {
                  print('onTapDown');
                  print(details.localPosition);
                },
                onTapUp: (details) {
                  print('onTapUp');
                  // print(details.localPosition);
                },
                onTap: () {
                  print('onTap');
                },
                onTapCancel: () {
                  print('onTapCancel');
                },
                onDoubleTap: () {
                  print('onDoubleTap');
                },
                onLongPress: () {
                  print('onLongPress');
                },
                onVerticalDragStart: (details) {
                  print('onVerticalDragStart');
                },
              ),
            ),
          ),
          Divider(height: 1.0),
          ListTile(
            title: Text('''
ProgressIndicator'''),
            subtitle: Column(
              children: <Widget>[
                SizedBox(height: 10.0),
                Text('LinearProgressIndicator'),
                LinearProgressIndicator(
                  value: this._linearProgress == 0.0 ? null : this._linearProgress, // value 为 null 时, 动画
                  backgroundColor: Colors.grey,
                  valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
                ),
                SizedBox(height: 20.0),
                Text('LinearProgressIndicator'),
                Row(
                  children: <Widget>[
                    CircularProgressIndicator(
                      value: this._circularProgress == 0.0 ? null : this._circularProgress,
                      backgroundColor: Colors.grey,
                    ),
                    SizedBox(width: 20.0),
                    CircularProgressIndicator(
                      value: this._circularProgress == 0.0 ? null : this._circularProgress,
                      valueColor: AlwaysStoppedAnimation<Color>(Colors.orangeAccent),
                      backgroundColor: Colors.grey,
                      strokeWidth: 10.0,
                    ),
                    SizedBox(width: 20.0),
                    Container(
                      width: 60.0,
                      height: 80.0,
                      child: CircularProgressIndicator(
                        value: this._circularProgress == 0.0 ? null : this._circularProgress,
                        valueColor: AlwaysStoppedAnimation<Color>(Colors.greenAccent),
                        backgroundColor: Colors.grey,
                        strokeWidth: 10.0,
                      ),
                    )
                  ],
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: <Widget>[
                    RaisedButton(
                      child: Text('Linear'),
                      onPressed: () {
                        setState(() {
                          this._linearProgress += 0.2;
                          if (this._linearProgress > 1.0) {
                            this._linearProgress = 0.0;
                          }
                        });
                      },
                    ),
                    RaisedButton(
                      child: Text('Circular'),
                      onPressed: () {
                        setState(() {
                          this._circularProgress += 0.2;
                          if (this._circularProgress > 1.0) {
                            this._circularProgress = 0.0;
                          }
                        });
                      },
                    ),
                  ],
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
